package com.example.studyplanning.mapper;

import com.example.studyplanning.entity.Focus;
import com.example.studyplanning.entity.Like;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FocusMapper {
    //1.5收藏，插入语句，输入心得ID和收藏用户ID
    @Insert("insert into focus(userID,tipsID) VALUES (#{userID},#{tipsID})")
    Integer InsertFocus(Focus focus);

    //5.4展示我的收藏,输入用户ID，展示收藏信息
    @Select("select tips.tipsTitle,tips.tipsContent,tips.tipsID,tips.likes,tips.tipsTime,user.userName,DATE_FORMAT(tips.tipsTime,'%Y-%m-%d') as date_time from tips INNER JOIN user on tips.userID=user.userID INNER JOIN focus on focus.tipsID=tips.tipsID where focus.userID=#{userID} order by tipsTime DESC")
    List<Focus> findAllFocus(Integer userID);

    //取消收藏
    @Delete("delete from focus where tipsID=#{tipsID}")
    Integer DelFocus(Integer tipsID);

    //显示是否已收藏数据
    @Select("select count(*) from focus where tipsID=#{tipsID} and userID=#{userID}")
    Integer FindFocus(@Param("userID")Integer userID, @Param("tipsID")Integer tipsID);
}
